package cn.hdmis.security.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/** 
  * @ClassName: Resources 
  * @Description:资源信息实体类
  * @author sunct sunchaotong18@163.com 
  * @date 2011-9-27 下午5:55:01 
  *  
  */

@Entity
@Table(name = "T_resources")
public class Resources  implements java.io.Serializable {
	private static final long serialVersionUID = -3554807899474392877L;
	 private Integer id;
     private Resources parent;
     private Systems system;
     private String name;
     private String enname;
     private String resourcetype;
     private String link;
     private String icon;
     private String iconopen;
     private String isopen;
     private String isleaf;
     private String status;
     private Integer orderid;
     private String memo;
     private Set<Resources> children = new HashSet<Resources>();
     private Set<Operation> resOperation = new HashSet<Operation>();
     
    @Id 
    @Column(name="id", unique=true, nullable=false)
    @GeneratedValue(strategy=GenerationType.AUTO)
    public Integer getId() {
        return this.id;
    }
	public void setId(Integer id) {
        this.id = id;
    }
	@ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="parent_id")
    public Resources getParent() {
        return this.parent;
    }
    public void setParent(Resources parent) {
        this.parent = parent;
    }
	@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="systemid")
    public Systems getSystem() {
        return this.system;
    }
    public void setSystem(Systems system) {
        this.system = system;
    }
    @Column(name="name", nullable=false, length=30)
    public String getName() {
        return this.name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name="enname", length=30)
    public String getEnname() {
        return this.enname;
    }
    public void setEnname(String enname) {
        this.enname = enname;
    }
    @Column(name="resourcetype", length=2)
    public String getResourcetype() {
        return this.resourcetype;
    }
    public void setResourcetype(String resourcetype) {
        this.resourcetype = resourcetype;
    }
    @Column(name="link", length=30)
    public String getLink() {
        return this.link;
    }
    public void setLink(String link) {
        this.link = link;
    }
    @Column(name="icon", length=30)
    public String getIcon() {
        return this.icon;
    }
    public void setIcon(String icon) {
        this.icon = icon;
    }
    @Column(name="iconopen", length=30)
    public String getIconopen() {
        return this.iconopen;
    }
    public void setIconopen(String iconopen) {
        this.iconopen = iconopen;
    }
    @Column(name="isopen", length=30)
    public String getIsopen() {
        return this.isopen;
    }
    public void setIsopen(String isopen) {
        this.isopen = isopen;
    }
    @Column(name="isleaf", nullable=false, length=30)
    public String getIsleaf() {
        return this.isleaf;
    }
    public void setIsleaf(String isleaf) {
        this.isleaf = isleaf;
    }
    @Column(name="status", nullable=false, length=30)
    public String getStatus() {
        return this.status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name="orderid")
    public Integer getOrderid() {
        return this.orderid;
    }
    public void setOrderid(Integer orderid) {
        this.orderid = orderid;
    }
    @Column(name="memo", length=50)
    public String getMemo() {
        return this.memo;
    }
    public void setMemo(String memo) {
        this.memo = memo;
    }
    @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="parent")
    public Set<Resources> getChildren() {
        return this.children;
    }
    public void setChildren(Set<Resources> children) {
        this.children = children;
    }
	/**
	 * @return the resOperation
	 */
    @ManyToMany(cascade={CascadeType.MERGE})
	@JoinTable(
			name="T_resource_operation",
			joinColumns={@JoinColumn(name="resource_id")},
			inverseJoinColumns={@JoinColumn(name="operation_id")}
	) 
	public Set<Operation> getResOperation() {
		return resOperation;
	}
	/**
	 * @param resOperation the resOperation to set
	 */
	public void setResOperation(Set<Operation> resOperation) {
		this.resOperation = resOperation;
	}
}